package com.example.lib.c1;

/**
 * 和谐停止
 */
public class Main5Interrupt {

    private static class Thread1 extends Thread {
        @Override
        public void run() {
            super.run();
            String name = getName();
            while (!isInterrupted()) {
                System.out.println(name + "---- is running " + isInterrupted());
            }
            System.out.println(name + "---- is end " + isInterrupted());
        }
    }

    public static void main(String[] args) throws InterruptedException {
        Thread1 thread1 = new Thread1();
        thread1.start();

        Thread.sleep(3000);
        thread1.interrupt();//发起中断信号
    }

}
